import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import ConfigElementType 1.0
import "qrc:/qmlComponents/ConfigManager"
import "qrc:/qmlComponents/AxisModulePos"
import "qrc:/qmlComponents/VisionViewer"
import "qrc:/qmlComponents/CustomizedUIElement/RowColumnSelectorView"

Item {
    ColumnLayout{
        RowLayout{
            XYModulePos{
                moduleName: "BWHOpticXY"
                posName: "PrLeftTop"
            }
            SAxisModulePos{
                moduleName: "BWHOpticZ"
                posName: "BondPrPos"
            }
            SAxisModulePos{
                moduleName: "BWHOpticZ"
                posName: "PostBondPrPos"
            }
        }

        RowLayout{
            VisionLocationViewer{
                visionLocationName: "STSensorLocation"
                performPrResultVisible: false
                calibrateBtnVisible: false
            }
            VisionLocationViewer{
                visionLocationName: "PostBondLocation"
                performPrResultVisible: false
                calibrateBtnVisible: false
            }
        }

        ColumnLayout{
            RowColumnSelector{
                rowColInfo: bwhRowColInfo
            }
            RowLayout{
                spacing: 10

                Button{
                    text: qsTr("MoveToPrPos")
                    onClicked: {
                        tem.runSingleCmd(bonderWorkHolder, "moveToPrPos",
                                         [bwhRowColInfo.unitRow, bwhRowColInfo.unitColumn, bwhRowColInfo.row, bwhRowColInfo.column])
                    }
                }
                Button{
                    text: qsTr("MoveToPerformSensorPr")
                    onClicked: {
                        tem.runSingleCmd(bonderWorkHolder, "moveToPerformSensorPr",
                                        [bwhRowColInfo.unitRow, bwhRowColInfo.unitColumn, bwhRowColInfo.row, bwhRowColInfo.column])
                    }
                }
                Button{
                    text: qsTr("MoveToPerformPostBondPr")
                    onClicked: {
                        tem.runSingleCmd(bonderWorkHolder, "moveToPerformPostBondPr",
                                         [bwhRowColInfo.unitRow, bwhRowColInfo.unitColumn, bwhRowColInfo.row, bwhRowColInfo.column])
                    }
                }
            }
        }

        RowLayout{
            spacing: 10
            ConfigRow{
                configModel: bwhConfig
                configName: "postBondLimitX"
                Component.onCompleted: {
                    init(ConfigElementType.Double)
                }
            }
            ConfigRow{
                configModel: bwhConfig
                configName: "postBondLimitY"
                Component.onCompleted: {
                    init(ConfigElementType.Double)
                }
            }
            CheckBox{
                id: ckbDoPostBond
                text: qsTr("DoPostBond")
                checked: true
            }
            Button{
                text: qsTr("Bond")
                onClicked: {
                    tem.runSingleCmd(bonderHead, "manuallyBond",
                                     [bwhRowColInfo.unitRow, bwhRowColInfo.unitColumn, bwhRowColInfo.row, bwhRowColInfo.column, ckbDoPostBond.checked])
                }
            }
        }
    }
}
